package com.example.spring.cloud.consumer.controller;

import com.example.spring.cloud.bean.User;
import com.example.spring.cloud.common.Result;
import com.example.spring.cloud.consumer.feign.UserFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/consumer/user")
public class UserController {

    @Autowired
    private UserFeign userFeign;

    @GetMapping("/add")
    public Result<User> add(User user) {
        return userFeign.add(user);
    }

    @GetMapping("/get/{id}")
    public Result<User> get(@PathVariable("id") Integer id) {
        return userFeign.get(id);
    }
}
